package com.shzu.jwc.ty.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shzu.jwc.ty.common.Msg;
import com.shzu.jwc.ty.bean.TheoreticalPaperModel;
import com.shzu.jwc.ty.service.PaperModelservice;

@Controller
@RequestMapping("papermodel")
public class PaperModelcontroller {

	@Autowired
	PaperModelservice papermodelservice;
	
	@RequestMapping(value="/papermodel.action")
	public String getPaperModel(Model model)
	{
		List<TheoreticalPaperModel> data=papermodelservice.getpapermodel();
		model.addAttribute("data", data);
		return "papermodel/papermodel";
	}
	
	@ResponseBody
	@RequestMapping("/addpapermodel.action")
	public Msg addpapermodel(TheoreticalPaperModel theoreticalPaperModel)
	{
		if(papermodelservice.insertpapermodel(theoreticalPaperModel)>0)
			return Msg.success("添加成功");
		else
			return Msg.error("添加失败");
	}
	
	@ResponseBody
	@RequestMapping("/deletepapermodel.action")
	public Msg deletepapermodel(@RequestParam("id") Integer theoreticalPaperModelId)
	{
		if(papermodelservice.deletepapermodel(theoreticalPaperModelId)>0)
			return Msg.success("删除成功");
		else
			return Msg.error("删除失败");
	}
	
	@ResponseBody
	@RequestMapping("/updatepapermodel.action")
	public Msg updatepapermodel(@RequestParam("id") Integer id,@RequestParam("column") String column,@RequestParam("value") Integer value)
	{
		if(papermodelservice.updatepapermodel(column, value, id)>0)
			return Msg.success("修改成功");
		else
			return Msg.error("修改失败");
	}
}
